<?php

namespace App\Admin\Controllers;

use App\Models\Circular;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;

class CircularController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new Circular(), function (Grid $grid) {
            $grid->column('title');
            $grid->column('begin_time');
            $grid->column('end_time');
            $grid->column('cover')->image('', 100, 100);
            $grid->column('updated_at')->sortable();

            $grid->filter(function (Grid\Filter $filter) {

            });
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new Circular(), function (Form $form) {
            $form->text('title');
            $form->datetimeRange('begin_time', 'end_time', '截止日期');
            $form->image('cover')->uniqueName();
            $form->editor('content');
        });
    }
}
